package com.ljye.jg.ljye.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.ljye.jg.ljye.R;
import com.ljye.jg.ljye.utils.CommonViewHolder;

import java.util.ArrayList;

import de.hdodenhof.circleimageview.CircleImageView;

public class Activity_Evaluate extends Activity {
    public View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.back://返回
                    finish();
                    break;

                default:
                    break;
            }
        }
    };

    private ImageView back;//返回
    private ArrayList<String> listData;
    private ListView lv;
    private MyAdpapter adpapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_evaluate);
        initView();
        initlistview();
        back.setOnClickListener(listener);
    }

    private void initlistview() {
        listData = new ArrayList<>();
        for (int i = 0; i <= 10; i++) {
            listData.add("天才宝贝" + i);
        }
        adpapter = new MyAdpapter();
        lv.setAdapter(adpapter);
    }

    private void initView() {
        back = (ImageView) findViewById(R.id.back);
        lv = (ListView) findViewById(R.id.lv);
    }

    public class MyAdpapter extends BaseAdapter {

        @Override
        public int getCount() {
            return listData == null ? 0 : listData.size();
        }

        @Override
        public Object getItem(int i) {
            return listData.get(i);
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {

            CommonViewHolder holder = CommonViewHolder.createCVH(view, viewGroup, R.layout.item_evaluate);

            CircleImageView headPortrait = (CircleImageView) holder.getView(R.id.head_portrait);//头像
            TextView uesrId = (TextView) holder.getTv(R.id.uesr_id);//用户名
            ImageView star1 = (ImageView) holder.getIv(R.id.star1);//星1
            ImageView star2 = (ImageView) holder.getIv(R.id.star2);//星2
            ImageView star3 = (ImageView) holder.getIv(R.id.star3);//星3
            ImageView star4 = (ImageView) holder.getIv(R.id.star4);//星4
            ImageView star5 = (ImageView) holder.getIv(R.id.star5);//星5
            TextView time = (TextView) holder.getTv(R.id.time);//日期时间
            TextView evaluate = (TextView) holder.getTv(R.id.evaluate);//评价内容
            LinearLayout imageMain = (LinearLayout) holder.getView(R.id.image_main);//图片集合
            ImageView image1 = (ImageView) holder.getIv(R.id.image1);//图片1
            ImageView image2 = (ImageView) holder.getIv(R.id.image2);//图片2
            ImageView image3 = (ImageView) holder.getIv(R.id.image3);//图片3
            ImageView image4 = (ImageView) holder.getIv(R.id.image4);//图片4
            TextView classTime = (TextView) holder.getTv(R.id.class_time);//课程时间
            TextView reply = (TextView) holder.getTv(R.id.reply);//回复

            String s = listData.get(i);
            uesrId.setText(s);

            return holder.convertView;

        }
    }
}
